<template>
  <el-dialog :model-value="visible" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false"
    width="500">
    <el-form :model="form">
      <el-form-item label="管理员手机号" label-width="100px">
        <el-input v-model="form.phoneNo" type="number" placeholder="请输入管理员手机号" autocomplete="off" />
      </el-form-item>
      <el-form-item label="管理员角色" label-width="100px">
        <el-select v-model="form.institutionRoleId" clearable placeholder="请选择管理员角色">
          <el-option v-for="item in roleData" :key="item.id" :label="item.name" :value="item.id" />
        </el-select>
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="cancelFn">取消</el-button>
        <el-button type="primary" @click="confirmFn">确认</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import { institutionRolePageList } from '~/server/api'
const props = defineProps({
  visible: {
    type: Boolean,
    default: false
  },
  forms: {
    type: Object
  }
})
const form = props.forms;
// 角色列表
const roleData = ref([])
const { data: roleRes } = await useAsyncData('institutionRolePageList', () => useServerRequest(institutionRolePageList, {
  method: 'post',
  body: JSON.stringify({
    pageNum: 1,
    pageSize: 100
  })
}))
if (roleRes.value && roleRes.value.errno === 0) {
  roleData.value = roleRes.value.result.list;
}
// 取消
const emit = defineEmits(['pick'])
const cancelFn = () => {
  emit('pick', { visible: false })
}
// 确认
const confirmFn = () => {
  emit('pick', { visible: false, form })
}
</script>

<style lang="less" scoped></style>